package models

import "my-yipuku/db"

type CouponPackage struct {
	ID        int     `json:"id"`
	Count     int     `json:"count"`
	Price     float64 `json:"price"`
	Prompt    string  `json:"prompt"`
	Remarks   string  `json:"remarks"`
	Status    int     `json:"status"`
	UpdatedAt string  `json:"updated_at"`
	CreatedAt string  `json:"created_at"`
	UpdatedBy string  `json:"updated_by"`
	CreatedBy string  `json:"created_by"`
}

/**
 * 查询优惠卷列表
 */
func (u CouponPackage) List() []CouponPackage {
	var couponPackages []CouponPackage
	db.Db.Where("status =?", 1).Select("id", "count", "price", "prompt", "remarks").Find(&couponPackages)
	return couponPackages
}

// 查询单个优惠卷信息
func (u CouponPackage) One(id int) CouponPackage {
	var couponPackage CouponPackage
	db.Db.First(&couponPackage, id)
	return couponPackage
}
